# $Id$
# Maintainer: Jürgen Hötzel <juergen@archlinux.org>
# Contributor: John Proctor <jproctor@prium.net>
# Contributor: Kevin Piche <kevin@archlinux.org>

pkgname=bigloo
_pkgver=4.3a
pkgver=${_pkgver/-/_}
pkgrel=1
pkgdesc="Fast scheme compiler"
arch=('i686' 'x86_64')
url="http://www-sop.inria.fr/mimosa/fp/Bigloo/"
license=('GPL' 'LGPL')
depends=('gmp' 'openssl' 'libunistring')
makedepends=('java-environment' 'emacs' 'zip' 'sqlite' 'alsa-lib' 'flac' 'avahi' 'chrpath')
optdepends=('java-environment' 'emacs' 'zip' 'sqlite' 'alsa-lib' 'flac' 'avahi')
options=('!makeflags')
source=(ftp://ftp-sop.inria.fr/indes/fp/Bigloo/${pkgname}${_pkgver}.tar.gz)
md5sums=('fb9dc882d01b2b7e8d6770a127657818')

elisp_dir=/usr/share/emacs/site-lisp/bigloo

build() {
  cd "${srcdir}/${pkgname}${_pkgver}"
  ./configure --prefix=/usr \
    --enable-ssl \
    --enable-sqlite \
    --lispdir=${elisp_dir} \
    --enable-avahi \
    --enable-flac \
    --disable-gstreamer \
    --mandir=/usr/share/man \
    --infodir=/usr/share/info \
    --docdir=/usr/share/doc/bigloo \
    --jvm=yes
  make build compile-bee
}

check() {
  cd "${srcdir}/${pkgname}${_pkgver}"
  make test
}

package() {
  cd "${srcdir}/${pkgname}${_pkgver}"

  make DESTDIR="${pkgdir}" install install-bee
  make -C manuals DESTDIR="${pkgdir}" install-bee

  chmod 644 "${pkgdir}"${elisp_dir}/etc/bass-snap.au \
	"${pkgdir}"${elisp_dir}/images/*

  rm ${pkgdir}/usr/bin/{bglafile,bigloo}.sh

  # Remove references to the build root
  sed -e "s|^BOOTDIR=.*|BOOTDIR=/usr|g" \
      -e "s|^BOOTBINDIR=.*|BOOTBINDIR=/usr/bin|g" \
      -e "s|^BOOTLIBDIR=.*|BOOTLIBDIR=/usr/lib/bigloo/${pkgver}|g" \
      -e "s|^BGLBUILDBINDIR=.*|BGLBUILDBINDIR=/usr/bin|g" \
      -e "s|^BGLBUILDLIBDIR=.*|BGLBUILDLIBDIR=/usr/lib/bigloo/${pkgver}|g" \
      -e "s|^\(BIGLOO=.*\)\.sh|\1|" \
      -e "s|^\(BGL.*=.*\)\.sh|\1|" \
      -i  ${pkgdir}/usr/lib/bigloo/${pkgver}/Makefile.config

}
